package ch5_1.StaticBroadcast.app.src.main.java.me.learningandroid.ch5_1.staticbroadcastdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private static final String SPREF_BOOTCOUNT="SPREF_BOOTCOUNT";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SharedPreferences sharedPreferences = getSharedPreferences("pref", Context.MODE_PRIVATE);
        int bootCount = sharedPreferences.getInt(SPREF_BOOTCOUNT,0);
        TextView msg = findViewById(R.id.msg);
        msg.setText(String.format("监听重启%s次", bootCount));
    }
}